package com.cwn.wizbank.scoket;
 
import java.sql.PreparedStatement;
import java.sql.SQLException;
import org.hibernate.HibernateException;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.identity.GetGeneratedKeysDelegate;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.PostInsertIdentityPersister;
 
 
public class DM8GetGeneratedKeysDelegate extends GetGeneratedKeysDelegate {
 
    private String[] keyColumns;
 
 
    public DM8GetGeneratedKeysDelegate(PostInsertIdentityPersister persister, Dialect dialect) {
        super(persister, dialect);
        this.keyColumns = getPersister().getRootTableKeyColumnNames();
        if ( keyColumns.length > 1 ) {
            throw new HibernateException( "Identity generator cannot be used with multi-column keys" );
        }
    }
 
    @Override
    protected PreparedStatement prepare(String insertSQL, SharedSessionContractImplementor session) throws SQLException {
        return session
            .getJdbcCoordinator()
            .getStatementPreparer()
            .prepareStatement( insertSQL, keyColumns );
    }
}
————————————————

                            版权声明：本文为博主原创文章，遵循 CC 4.0 BY-SA 版权协议，转载请附上原文出处链接和本声明。
                        
原文链接：https://blog.csdn.net/li18310727696/article/details/125088440